package com.yu.mall.util;

import com.alibaba.fastjson.JSON;
import com.yu.mall.vo.ResultVO;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ResponseUtils {

    public static boolean write(HttpServletResponse response, String data) throws IOException {
        response.setCharacterEncoding("UTF-8");
        response.setHeader("Content-type", "text/html;charset=UTF-8");
        response.getWriter().write(data);
        return false;
    }

    public static boolean writeJson(HttpServletResponse response, ResultVO result) throws IOException {
        response.setCharacterEncoding("UTF-8");
        response.setHeader("Content-type", "text/html;charset=UTF-8");
        return write(response,JSON.toJSONString(result));
    }

}
